package com.xcity.game.common;

import com.xcity.game.item.ItemInfo;
import com.xcity.game.item.ItemTemplate;

public class ItemResponse extends ItemInfo {

	protected String name;
	protected String icon;
	protected String desc;
	protected byte quality = -1;
	
	public ItemResponse() {}
	
	public ItemResponse(int id, int count) {
		this.id = id;
		this.count = count;
	}
	
	public ItemResponse(ItemTemplate template, int count) {
		super(template, count);
	}
	
	public ItemResponse(ItemInfo ref) {
		this(ref.getId(), ref.getCount(), ref.getTemplate().getName(), ref.getTemplate().getIcon(), ref.getTemplate().getDesc(), ref.getTemplate().getQuality());
		this.template = ref.getTemplate();
	}
	
	public ItemResponse(int id, int count, String name, String icon, String desc) {
		this(id, count, name, icon, desc, (byte) 1);
	}
	
	public ItemResponse(int id, int count, String name, String icon, String desc, byte quality) {
		this.id = id;
		this.count = count;
		this.name = name;
		this.icon = icon;
		this.desc = desc;
		this.quality = quality;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public int getCount() {
		return count;
	}

	public void setCount(int count) {
		this.count = count;
	}

	public String getName() {
		return name != null ? name : (name = getTemplate().getName());
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getIcon() {
		return icon != null ? icon : (icon = getTemplate().getIcon());
	}

	public void setIcon(String icon) {
		this.icon = icon;
	}

	public String getDesc() {
		return desc != null ? desc : (desc = getTemplate().getDesc());
	}

	public void setDesc(String desc) {
		this.desc = desc;
	}

	public byte getQuality() {
		return quality != -1 ? quality : (quality = getTemplate().getQuality());
	}

	public void setQuality(byte quality) {
		this.quality = quality;
	}

}
